<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>unzip_file (StartProject::Downloader)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/start_project/downloader.rb, line 18</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unzip_file</span> (<span class="ruby-identifier">destination</span>)
      <span class="ruby-identifier">orig_name</span> = <span class="ruby-value str">&quot;&quot;</span>
      <span class="ruby-constant">Zip</span><span class="ruby-operator">::</span><span class="ruby-constant">ZipFile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">&quot;temp.zip&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">zip_file</span><span class="ruby-operator">|</span>
       <span class="ruby-identifier">zip_file</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
         <span class="ruby-identifier">f_path</span>=<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;./&quot;</span>, <span class="ruby-identifier">f</span>.<span class="ruby-identifier">name</span>)
         <span class="ruby-identifier">orig_name</span> = <span class="ruby-identifier">f_path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>)[<span class="ruby-value">1</span>]
         <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f_path</span>))
         <span class="ruby-identifier">zip_file</span>.<span class="ruby-identifier">extract</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">f_path</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">f_path</span>)
       }
      }
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">rename</span>(<span class="ruby-identifier">orig_name</span>, <span class="ruby-identifier">destination</span>)
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;temp.zip&quot;</span>)
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>